package com.javacon;

import com.cltolarva.CheckCLConflictTemp;

public aspect TestAspect {
	
	String clFileName=null;
	CheckCLConflictTemp ckc=null;
	
	public TestAspect(){
		//System.out.print("This run one time");
		this.clFileName="D:\\testcl.txt";
		
		ckc=new CheckCLConflictTemp(this.clFileName);
		//System.out.print("This run one time");
	}
	
	//this line need to change for make it universal
	pointcut methodCall() : call(* loginlogoutrequest.*(..));
	
	before() : methodCall() {

		String fullMethoadName=thisJoinPoint.toString();
		//get method Name
		String fullMethoadName1=thisJoinPoint.getSignature().getName();
		
		//thisJoinPoint.getTarget();
		//doVerification(fullMethoadName);
		//printMessage(fullMethoadName1);
		checkConflict(fullMethoadName1);
		
	}
	
	public void printMessage(String methodName){
		System.out.println(">>>>>"+methodName+" : Method Calling");
	}
	
	public void checkConflict(String methodName){
		
		System.out.println("A test line");
		
		System.out.println(methodName);
		
		System.out.println(this.ckc.allMonitors.size());
		
		if(this.ckc.getCLMonitor(methodName).getRelatedMethod().equals(methodName)&& methodName!="read"){
			//System.out.println(this.ckc.getCLMonitor(methodName).getClContact().toString());
			System.out.println("method Mached");
		}
		
		/*if(this.ckc.allMonitors.size()!=0)
			System.out.println(this.ckc.getCLMonitor(methodName).getClContact());*/
	}

}
